package com.spring.boot.springBoot.schedule.quartzSchedule.factory;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;

/**
 * Created by pactera on 2018/1/10.
 */
@Component
public class SpiritJobFactory extends AdaptableJobFactory {


    @Autowired
    private AutowireCapableBeanFactory autowireCapableBeanFactory;

    @Override
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
        Object instanceJob = super.createJobInstance(bundle);
        autowireCapableBeanFactory.autowireBean(instanceJob);
        return instanceJob;
    }
}
